/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package py.com.peluq.model.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Diego_M
 */
@Entity
@Table(name = "cob_cheque", catalog = "peludb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CobCheque.findAll", query = "SELECT c FROM CobCheque c"),
    @NamedQuery(name = "CobCheque.findByCobCod", query = "SELECT c FROM CobCheque c WHERE c.cobChequePK.cobCod = :cobCod"),
    @NamedQuery(name = "CobCheque.findByEntEmisoraCod", query = "SELECT c FROM CobCheque c WHERE c.cobChequePK.entEmisoraCod = :entEmisoraCod"),
    @NamedQuery(name = "CobCheque.findByCheNro", query = "SELECT c FROM CobCheque c WHERE c.cobChequePK.cheNro = :cheNro"),
    @NamedQuery(name = "CobCheque.findByCheMonto", query = "SELECT c FROM CobCheque c WHERE c.cheMonto = :cheMonto"),
    @NamedQuery(name = "CobCheque.findByCheFecha", query = "SELECT c FROM CobCheque c WHERE c.cheFecha = :cheFecha"),
    @NamedQuery(name = "CobCheque.findByCheTitular", query = "SELECT c FROM CobCheque c WHERE c.cheTitular = :cheTitular")})
public class CobCheque implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CobChequePK cobChequePK;
    @Column(name = "che_monto")
    private Integer cheMonto;
    @Column(name = "che_fecha")
    @Temporal(TemporalType.DATE)
    private Date cheFecha;
    @Size(max = 100)
    @Column(name = "che_titular", length = 100)
    private String cheTitular;
    @JoinColumn(name = "ent_emisora_cod", referencedColumnName = "ent_emisora_cod", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private EntidadEmisora entidadEmisora;
    @JoinColumn(name = "cob_cod", referencedColumnName = "cob_cod", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Cobro cobro;

    public CobCheque() {
    }

    public CobCheque(CobChequePK cobChequePK) {
        this.cobChequePK = cobChequePK;
    }

    public CobCheque(int cobCod, int entEmisoraCod, int cheNro) {
        this.cobChequePK = new CobChequePK(cobCod, entEmisoraCod, cheNro);
    }

    public CobChequePK getCobChequePK() {
        return cobChequePK;
    }

    public void setCobChequePK(CobChequePK cobChequePK) {
        this.cobChequePK = cobChequePK;
    }

    public Integer getCheMonto() {
        return cheMonto;
    }

    public void setCheMonto(Integer cheMonto) {
        this.cheMonto = cheMonto;
    }

    public Date getCheFecha() {
        return cheFecha;
    }

    public void setCheFecha(Date cheFecha) {
        this.cheFecha = cheFecha;
    }

    public String getCheTitular() {
        return cheTitular;
    }

    public void setCheTitular(String cheTitular) {
        this.cheTitular = cheTitular;
    }

    public EntidadEmisora getEntidadEmisora() {
        return entidadEmisora;
    }

    public void setEntidadEmisora(EntidadEmisora entidadEmisora) {
        this.entidadEmisora = entidadEmisora;
    }

    public Cobro getCobro() {
        return cobro;
    }

    public void setCobro(Cobro cobro) {
        this.cobro = cobro;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cobChequePK != null ? cobChequePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CobCheque)) {
            return false;
        }
        CobCheque other = (CobCheque) object;
        if ((this.cobChequePK == null && other.cobChequePK != null) || (this.cobChequePK != null && !this.cobChequePK.equals(other.cobChequePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "py.com.peluq.model.entity.CobCheque[ cobChequePK=" + cobChequePK + " ]";
    }
    
}
